// ranking.js
var iconUrl = require('../../config.js').iconUrl;
var cmds = require('../../utils/cmd.js');
var blu=require('../../utils/blue.js');
Page({
  /**
   * 页面的初始数据
   */
  data: {
    iconUrl: iconUrl,
    me: {
      nick_name: "中未智联",
      icon: "https://zwzlcloud.ocmcom.com/data/smallapp/icon/NO.3.png",
      zan: 0,
      bracelet_id: 0,
      sort: 0,
      sport_calorie: 0,
      pace:0,      
      mileage:0,
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showNavigationBarLoading();
    var sort = options.sort;
    var zan =  options.zan;
    var icon = options.icon;    
    var me=this.data.me;
    me.sort=sort;
    me.zan=zan;
    me.icon=icon;
    this.setData({
      me: me
    });
    this.onPullDownRefresh();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.onPullDownRefresh();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    var that = this;
    blu.blue_write(cmds.set6_2());
    setTimeout(function () {
      var me=that.data.me;
      me.pace = wx.getStorageSync("bracelet_data.current_pace");
      me.mileage = wx.getStorageSync("bracelet_data.current_mileage");
      me.sport_calorie = wx.getStorageSync("bracelet_data.current_calorie");
      if (me.sport_calorie.startsWith(":")){
         me.sport_calorie = me.sport_calorie.substr(1);       
      }      
      wx.hideNavigationBarLoading();
      wx.stopPullDownRefresh();           
      that.setData({
        me: me
      });
    }, 2000);
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})